var a = getApp();

Page({
    data: {
        tabActive: 1,
        requestRul: "plugin.redpack-user.frontend.sendLog.index",
        total: 0,
        page: 1,
        finished: !1
    },
    onLoad: function(a) {},
    onShow: function() {
        this.getData();
    },
    getData: function() {
        var e = this, t = a.getNetAddresss(this.data.requestRul);
        a._getNetWork({
            url: t,
            success: function(a) {
                if (1 === a.data.result) {
                    var t = a.data.data.list, i = !1;
                    (e.data.page >= t.last_page || t.data.length < t.per_page) && (i = !0), e.setData({
                        page: ++e.data.page,
                        finished: i,
                        recordList: t.data
                    });
                } else wx.showToast({
                    title: a.data.msg
                });
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (!this.data.finished) {
            var t = a.getNetAddresss(this.data.requestRul);
            wx.showLoading({
                title: "加载中"
            }), a._getNetWork({
                url: t,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    if (wx.hideLoading(), 1 === a.data.result) {
                        var t = a.data.data.list, i = !1, s = e.data.recordList.concat(t.data);
                        (e.data.page >= t.last_page || t.data.length < t.per_page) && (i = !0), e.setData({
                            page: ++e.data.page,
                            finished: i,
                            recordList: s
                        });
                    } else wx.showToast({
                        title: a.data.msg
                    });
                },
                fail: function() {
                    wx.hideLoading();
                }
            });
        }
    },
    onChange: function(a) {
        var e = "";
        e = 1 == a.detail.name ? "plugin.redpack-user.frontend.sendLog.index" : "plugin.redpack-user.frontend.receiveLog.index", 
        this.setData({
            page: 1,
            finished: !1,
            requestRul: e,
            tabActive: a.detail.name
        }), this.getData();
    },
    goPersonRedDetail: function(a) {
        var e = a.currentTarget.dataset.rid;
        wx.navigateTo({
            url: "/packageI/personRed/personListDetail/personListDetail?rid=".concat(e)
        });
    },
    goPersonRedRecord: function(a) {
        var e = a.currentTarget.dataset.rid;
        wx.navigateTo({
            url: "/packageI/personRed/personRedRecord/personRedRecord?rid=".concat(e)
        });
    },
    onReachBottom: function() {
        this.getMoreData();
    }
});